package com.sl.biz.modular.ai.model;

import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.zhipuai.ZhiPuAiChatModel;
import org.springframework.ai.zhipuai.ZhiPuAiChatOptions;
import org.springframework.ai.zhipuai.api.ZhiPuAiApi;
import org.springframework.stereotype.Component;

@Component("zhipuai")
public class ZhipuChatModelService implements IChatModelService{
    @Override
    public ChatModel getChatModel(String token) {

        ZhiPuAiApi openAiApi  =new ZhiPuAiApi(token);

        //OpenAiApi.ChatModel.GPT_4_O
        //response format wait
        ZhiPuAiChatOptions zhiPuAiChatOptions =ZhiPuAiChatOptions.builder().withModel(ZhiPuAiApi.DEFAULT_CHAT_MODEL)
                .withTemperature(0.7f).build();

        ChatModel myChatModel =  new ZhiPuAiChatModel(openAiApi,zhiPuAiChatOptions); // usually autowired

        return myChatModel;
    }
}
